const User = require('../models/user');
const { sequelize } = require('../config/database');

async function createAdminUser() {
  try {
    // 创建管理员用户
    const adminUser = await User.create({
      email: 'admin@biaowang.com',
      password: 'admin123456', // 密码会通过hooks自动加密
      role: 'admin',
      isVerified: true,
      virtualCoins: 1000
    });

    console.log('管理员账号创建成功：', {
      email: adminUser.email,
      role: adminUser.role
    });

    // 关闭数据库连接
    await sequelize.close();
  } catch (error) {
    console.error('创建管理员账号失败：', error);
    await sequelize.close();
    process.exit(1);
  }
}

createAdminUser();